package com.java.simple.study.juc.p3.reentrant;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author zhoujl
 * @date 2022/5/10 21:40
 * @desc
 */
@Slf4j(topic = "c.TestReentrantLock")
public class TestReentrantLock {
    static final ReentrantLock lock = new ReentrantLock();

    public static void main(String[] args) {
        m1();
    }

    public static void m1() {
        lock.lock();
        try {
            log.debug("execute m1...");
            m2();
        } finally {
            lock.unlock();
        }
    }

    public static void m2() {
        lock.lock();
        try {
            log.debug("execute m2...");
            m3();
        } finally {
            lock.unlock();
        }
    }

    public static void m3() {
        lock.lock();
        try {
            log.debug("execute m3...");
        } finally {
            lock.unlock();
        }
    }

}
